# coding=utf-8

import wx
import urllib.request
class Myframe(wx.Frame):
	def __init__(self):
		super().__init__(None,title='下载器',size=(400,300))
		panel = wx.Panel(parent=self)
		text = wx.TextCtrl(panel)
		button = wx.Button(parent=panel,id=10,lable='确定')
		
		tc = wx.StaticText(panel,label="请输入一个网址")
		
		hbox = wx.Sizer(wx.HORZONAL)
		hbox.Add(button,porportion=1,flag=wx.ALL,border=5)
		hbox.Add(tc,flag=wx.LEFT,border=5)
		hbox.Add(text,flag=wx.LEFT,border=5)
		
		vbox = wx.Sizer(wx.VERTICAL)
		vbox.Add(hbox,flag=wx.ALL,border=10)
		
		url = tc.GetValue()
		def download(url):
			global url
			req = urllib.request.Request(url)
			try:
				with urllib.request.urlopen(req) as response:
					data = response.read()
					print(str(data))
			except ValueError as e:
				print('您插入了一个无法打开的网址,错误:{0}'.format(e))

frm1 = MyFrame()
frm1.show()